<?php
class Sample_Index_Action extends NICED_Action 
{    
    public function execute() 
    {   
        $cacher = MemcacheFactory::create('query_memcache');
        $named_cacher = new NICED_NamespacedMemcache($cacher, "cloudsearch");
        $named_cacher->set("name", "mytesting");
        echo "get from memcached: ".$named_cacher->get("name");
        $controller = $this->getController();
        $request    = $controller->getRequest();    
    
        $model = $controller->getModel('Sample.Index');
        $dao = NICED_DaoFactory::create('test');
        $dao->setDriverType('pdo');
        $sql = $dao->getSQLWrapper();
        $sql->setWhat('id, name');
        $sql->appendWhere("id=2");
        //$sql->appendGroup('id');
        //$sql->appendGroup('name');
        NICED_PRINT($sql->toString());
         //$txn = new NICED_TransactionDao();
         //$txn->attach($dao);
        $rs = $dao->execute();
		if (!$rs->isSuccess())
		{
				throw new NICED_Exception("db error");
		}

        NICED_PRINT($rs->fetchRow());
         $cache = MemcacheFactory::create('query_memcache');
         //$cache->delete('name');
    
        try 
        {   
            $message = $model->hello();
        }   
        catch (Exception $e) 
        {   
            $controller->handleException(new NICED_Exception($e->getMessage()));
            return self::SUCCESS;
        }   

        return self::SUCCESS;
    }   

}//end class
